<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_LOCALES_COLLECTION_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="MENU_ITEM_PARENT_ID_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="OWNER_INFO_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="MENU_ITEM_OWNER_ID_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="MENU_ITEM_PARENTS_LIST_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="REDIRECT_URL_KEY" scope="page" />

<c:set var="redirectUrl" value="${sessionScope[pageScope.REDIRECT_URL_KEY]}" />
<c:set var="redirectUrlPresents" value="${redirectUrl != null && redirectUrl != ''}" />

<c:set var="isInRoot" value="${sessionScope[pageScope.MENU_ITEM_PARENT_ID_KEY] == null}" />
<c:set var="ignoreValue" value="true" />
<c:if test="${!requestScope.menuItem.dynamic}">
	<c:set var="ignoreValue" value="false" />
</c:if>
<atleap:content identifier="information" ignore="true" />
<c:set var="parentsList" value="${requestScope[pageScope.MENU_ITEM_PARENTS_LIST_KEY]}" />
<c:set var="path" value="" />
<c:if test="${parentsList != null}">
	<atleap:iterator items="${parentsList}" var="parentItem" statusVar="listStatus">
		<atleap:fieldValue valueMap="${parentItem.title}" var="titleKey" />
		<atleap:message key="${titleKey}" var="titleMsg" ignore="true" />
		<c:if test="${empty titleMsg}">
			<c:set var="titleMsg" value="${titleKey}" />
		</c:if>
		<atleap:message key="core.menuItem.form.goToItem" arg0="${titleMsg}" var="linkTitle" />
		<c:set var="path" value="${path}${titleMsg}" />
		<c:if test="${!listStatus.last}">
			<c:set var="path" value="${path}&nbsp;&gt;&nbsp;" />
		</c:if>
	</atleap:iterator>
</c:if>
<table cellpadding="2" cellspacing="0" border="0" class="tableView">
	<c:if test="${!empty path}">
		<tr>
			<th colspan="2" style="text-align: center;">
				<atleap:message key="core.menuItem.form.path" arg0="${path}" />
			</th>
		</tr>
	</c:if>
	<tr>
		<th>
			<atleap:message key="core.menuItem.form.ownerInfo" />
		</th>
		<td>
			<c:choose>
				<c:when test="${!empty requestScope[pageScope.OWNER_INFO_KEY]}">
					${requestScope[pageScope.OWNER_INFO_KEY]}
					<atleap:link action="core/localizable/view?id=${requestScope[pageScope.MENU_ITEM_OWNER_ID_KEY]}">
						<atleap:message key="core.commons.buttons.goTo" />
					</atleap:link>
				</c:when>
				<c:otherwise>
					<atleap:message key="core.menuItem.form.owner.baseLayer" />
				</c:otherwise>
			</c:choose>
		</td>
	</tr>
	<tr>
		<th>
			<atleap:message key="core.menuItem.form.title" />
		</th>
		<td>
			<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
				<div class="readOnlyField">
					<atleap:fieldValue valueMap="${requestScope.menuItem.title}" language="${contentLocale.identifier}" var="titleKey" complexSearch="${ignoreValue}" />
					<atleap:message key="${titleKey}" var="titleMsg" language="${contentLocale.identifier}" ignore="true" />
					<c:if test="${empty titleMsg}">
						<c:set var="titleMsg" value="${titleKey}" />
					</c:if>
					<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
					<c:if test="${empty languageTitle}">
						<c:set var="languageTitle" value="${contentLocale.identifier}" />
					</c:if>
					${languageTitle}:&nbsp;${titleMsg}
				</div>
			</atleap:iterator>
		</td>
	</tr>
	<tr>
		<th>
			<atleap:message key="core.menuItem.form.toolTip" />
		</th>
		<td>
			<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
				<div class="readOnlyField">
					<atleap:fieldValue valueMap="${requestScope.menuItem.toolTip}" language="${contentLocale.identifier}" var="toolTipKey" complexSearch="${ignoreValue}" />
					<atleap:message key="${toolTipKey}" var="toolTipMsg" language="${contentLocale.identifier}" ignore="true" />
					<c:if test="${empty toolTipMsg}">
						<c:set var="toolTipMsg" value="${toolTipKey}" />
					</c:if>
					<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
					<c:if test="${empty languageTitle}">
						<c:set var="languageTitle" value="${contentLocale.identifier}" />
					</c:if>
					${languageTitle}:&nbsp;${toolTipMsg}
				</div>
			</atleap:iterator>
		</td>
	</tr>
	<c:if test="${isInRoot && !empty requestScope.menuItem.identifier}">
		<tr>
			<th><atleap:message key="core.menuItem.form.identifier" /></th>
			<td>
				<c:out value="${requestScope.menuItem.identifier}" escapeXml="true" />
			</td>
		</tr>
	</c:if>
	<c:if test="${!isInRoot}">
		<tr>
			<th><atleap:message key="core.menuItem.form.location" /></th>
			<td>
                <c:choose>
                    <c:when test="${!empty requestScope.menuItem.location}">
				        <c:out value="${requestScope.menuItem.location}" escapeXml="true" />
                    </c:when>
                    <c:otherwise>
                        <atleap:message key="core.commons.notSpecified" />
                    </c:otherwise>
                </c:choose>
			</td>
		</tr>
	</c:if>
    <tr>
		<th><atleap:message key="core.menuItem.form.align" /></th>
		<td>
			<c:if test="${!empty requestScope.menuItem.align}">
				<atleap:message key="core.menuItem.form.align.${requestScope.menuItem.align}" />
			</c:if>
		</td>
	</tr>
    <tr>
		<th><atleap:message key="core.menuItem.form.style" /></th>
		<td>
			<c:out value="${requestScope.menuItem.style}" escapeXml="true" />
		</td>
	</tr>
    <tr>
		<th><atleap:message key="core.menuItem.form.styleClass" /></th>
		<td>
			<c:out value="${requestScope.menuItem.styleClass}" escapeXml="true" />
		</td>
	</tr>
    <tr>
		<th><atleap:message key="core.menuItem.form.styleId" /></th>
		<td>
			<c:out value="${requestScope.menuItem.styleId}" escapeXml="true" />
		</td>
	</tr>
    <tr>
		<th><atleap:message key="core.menuItem.form.image" /></th>
		<td>
			<c:choose>
				<c:when test="${!empty requestScope.menuItem.image}">
					<img src="${requestScope.menuItem.image}" border="0" />
				</c:when>
				<c:otherwise>
					<atleap:message key="core.commons.notSpecified" />
				</c:otherwise>
			</c:choose>
		</td>
	</tr>
    <tr>
		<th><atleap:message key="core.menuItem.form.altImage" /></th>
		<td>
			<c:choose>
				<c:when test="${!empty requestScope.menuItem.altImage}">
					<img src="${requestScope.menuItem.altImage}" border="0" />
				</c:when>
				<c:otherwise>
					<atleap:message key="core.commons.notSpecified" />
				</c:otherwise>
			</c:choose>
		</td>
	</tr>
    <tr>
		<th><atleap:message key="core.menuItem.form.target" /></th>
		<td>
			<c:out value="${requestScope.menuItem.target}" escapeXml="true" />
		</td>
	</tr>
    <tr>
		<th><atleap:message key="core.menuItem.form.hreflang" /></th>
		<td>
			<c:out value="${requestScope.menuItem.hreflang}" escapeXml="true" />
		</td>
	</tr>
    <tr>
		<th><atleap:message key="core.menuItem.form.visibility" /></th>
		<td>
			<atleap:message key="core.menuItem.form.visibility.${requestScope.menuItem.visibility}" />
		</td>
	</tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.menuItem.form.roles" /></th>
        <td><c:out value="${requestScope.menuItem.rolesAsString}" escapeXml="true" /></td>
    </tr>
</table>
<br />
<atleap:form action="core/menuItem/callUpdate" method="GET" validateOnSubmit="false">
    <html:hidden property="id" value="${requestScope.menuItem.id}" />
	<html:hidden property="ownerId" value="${requestScope.ownerId}" />
    <atleap:isUserInRole roles="core-menuItem-update">
        <atleap:submit styleClass="button" disabled="${!requestScope.canUpdate}"><atleap:message key="core.commons.buttons.callUpdate" /></atleap:submit>
    </atleap:isUserInRole>
    <atleap:cancel styleClass="button">
        <c:choose>
            <c:when test="${redirectUrlPresents}">
                <atleap:message key="core.commons.buttons.back" />
            </c:when>
            <c:otherwise>
                <atleap:message key="core.commons.buttons.showList" />
            </c:otherwise>
        </c:choose>
    </atleap:cancel>
</atleap:form>
